package fy.test;

import org.json.JSONException;

import fy.form.listen.set.OA_UAPAccountContrast;
import fy.uap.bean.MergerProviderFormBean;
import fy.uap.dao.MergerProviderFormDao;
import fy.util.MyUtil;

public class Rest_MergerProviderFormOperator extends AForm_Save_Operator_Rest {

    private fy.uap.bean.MergerProviderFormBean mpfb = new MergerProviderFormBean();

    private long memberID;

    public String getFormName() {
        return "更名/合并供应商登记审批表";
    }

    public boolean save() {

        MergerProviderFormDao mpfd = new MergerProviderFormDao();

        mpfd.setMergerProviderFormBean(mpfb);
        if (!MyUtil.strIsNotNull(mpfb.getNewProviderCode())) {
            mpfb.setNewProviderCode(mpfb.getOldProviderCode());
        }

        mpfd.save();
        return false;
    }

    @Override
    protected void parseValueExport(String name, String value) {
        if ("原供应商编码".equals(name)) {
            mpfb.setOldProviderCode(MyUtil.clearEmpty(value));
        } else if ("原供应商名称".equals(name)) {
            mpfb.setOldProviderName(MyUtil.replaceXMLString(value));
        } else if ("目标供应商编码".equals(name)) {
            mpfb.setNewProviderCode(MyUtil.replaceXMLString(value));
        } else if ("目标供应商名称".equals(name)) {
            mpfb.setNewProviderName(MyUtil.replaceXMLString(value));
        } else if ("是否更名".equals(name)) {
            mpfb.setChangeName("0".equals(value));
        } else if ("信息是否改变".equals(name)) {
            mpfb.setChangeInfo("0".equals(value));
        } else if ("更名合并供应商_制造部选择器".equals(name)) {
//			String uapAccount = OA_UAPAccountContrast.getUapAccountID(value);
            mpfb.setCompany(OA_UAPAccountContrast.getUapAccountID(value));
        } else if ("原因说明".equals(name)) {
            mpfb.setReason(MyUtil.replaceXMLString(value));
        } else if ("同类供应商".equals(name)) {
            mpfb.setSimilarSuppliers(MyUtil.replaceXMLString(value));
        } else if ("企业地址".equals(name)) {
            mpfb.setAddress(MyUtil.replaceXMLString(value));
        } else if ("联系人".equals(name)) {
            mpfb.setLinkman(MyUtil.replaceXMLString(value));
        } else if ("供货周期".equals(name)) {
            mpfb.setSupplyCycle(MyUtil.replaceXMLString(value));
        } else if ("结算银行".equals(name)) {
            mpfb.setCvenbank(MyUtil.replaceXMLString(value));
        } else if ("发货地址".equals(name)) {
            mpfb.setSupplyAddress(MyUtil.replaceXMLString(value));
        } else if ("电话号码".equals(name)) {
            mpfb.setTel(MyUtil.replaceXMLString(value));
        } else if ("发票税码".equals(name)) {
            mpfb.setCpurbillcode(MyUtil.replaceXMLString(value));
        } else if ("银行账号".equals(name)) {
            mpfb.setBankAccount(MyUtil.replaceXMLString(value));
        } else if ("税务登记号".equals(name)) {
            mpfb.setTaxRegister(MyUtil.replaceXMLString(value));
        } else if ("传真号码".equals(name)) {
            mpfb.setFax(MyUtil.replaceXMLString(value));
        } else if ("物流方式PK".equals(name)) {
            mpfb.setCouttype(value);
        } else if ("币种PK".equals(name)) {
            mpfb.setCmoneytype(value);
        } else if ("质量体系".equals(name)) {
            mpfb.setQualitySystem(MyUtil.replaceXMLString(value));
        } else if ("邮编".equals(name)) {
            mpfb.setPostCode(MyUtil.replaceXMLString(value));
        } else if ("企业类型PK".equals(name)) {
            mpfb.setCompanyType(value);
        } else if ("付款条件".equals(name)) {
            mpfb.setCcuspaycond(MyUtil.replaceXMLString(value));
        } else if ("属性".equals(name)) {
            mpfb.setProperty(MyUtil.replaceXMLString(value));
        } else if ("电子邮箱".equals(name)) {
            mpfb.setEmail(MyUtil.replaceXMLString(value));
        } else if ("价格条款".equals(name)) {
            mpfb.setCcontent(MyUtil.replaceXMLString(value));
        } else if ("单据编号".equals(name)) {
            mpfb.setNumber(value);
        } else if ("开户银行".equals(name)) {
            mpfb.setcVenBankMemo(MyUtil.replaceXMLString(value));
        } else if ("银行开户名".equals(name)) {
            mpfb.setBankAccountName(MyUtil.replaceXMLString(value));
        } else if ("银行代码".equals(name)) {
            mpfb.setBankCode(MyUtil.replaceXMLString(value));
        } else if ("企业类别".equals(name)) {
            mpfb.setQylb(MyUtil.replaceXMLString(value));
        } else if ("注册资金".equals(name)) {
            mpfb.setZczj(MyUtil.replaceXMLString(value));
        } else if ("成立时间".equals(name)) {
            mpfb.setClsj(MyUtil.replaceXMLString(value));
        } else if ("职工总人数".equals(name)) {
            mpfb.setZgrs(MyUtil.replaceXMLString(value));
        } else if ("经营场所".equals(name)) {
            mpfb.setJycs(MyUtil.replaceXMLString(value));
        } else if ("法人代表".equals(name)) {
            mpfb.setFrdb(MyUtil.replaceXMLString(value));
        } else if ("法人代表身份证".equals(name)) {
            mpfb.setFrdbsfz(MyUtil.replaceXMLString(value));
        } else if ("年销售额".equals(name)) {
            mpfb.setNxse(MyUtil.replaceXMLString(value));
        } else if ("日期".equals(name)) {
            mpfb.setApplicationDate(MyUtil.getDate(value));
        } else if ("人员选择器".equals(name)) {
            memberID = Long.valueOf(MyUtil.strIsNotNull(value) ? value : "0");
            try {
                mpfb.setMemberCode(Fy_OrgManager.getMember(memberID).getString(
                        "code"));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

}
